<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	积分、余额日志
*/
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid']);
	$return['params']=array();
	//时间范围
	if($_RQ['day']){
		$return['params']['day']=$_RQ['day'];
		$daytime=strtotime($_RQ['day']);
		$params['day']=date('Y-m',$daytime);
	}
	$list=pdo_getslice('jy_mjifee_feelog',$params,array($pindex,$psize),$total,array(),'','id desc');
	foreach($list as &$item){
		$item['goodstitle']=pdo_getcolumn('jy_weishop_goods',array('id'=>$item['goodsid'],'uniacid'=>$_SESSION['uniacid']),'title');
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'分红记录'),
		),
		'list'=>array('data'=>'list','tip'=>'[温馨提示]：<red>店铺/部门/个人销售额=(销售额-单品销售额)；</red>','edit'=>false,'list'=>array(
			array('name'=>'day','title'=>'月份','type'=>'string'),
			array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'feelog_type'),
			array('name'=>'goodstitle','title'=>'商品','type'=>'string'),
			array('name'=>'orderprice','title'=>'销售额','type'=>'string'),
			array('name'=>'tui_fee','title'=>'直推分红','type'=>'string'),
			array('name'=>'bm_fee','title'=>'部门分红','type'=>'string'),
			array('name'=>'dian_fee','title'=>'店铺分红','type'=>'string'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		)),
		'search'=>array(
			array('type'=>'time','width'=>18,'title'=>'月份','name'=>'day','help'=>''),
		),
	);
	$return['feelog_type'] =$this->feelog_type;
	exi($return);
}
if($_RQ['op'] == 'del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_mjifee_feelog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_mjifee_feelog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
			}
		}
	}
	exi('删除成功！');
}